package es.udc.emarketapp.emarket.model.productFacade.actions;

import java.sql.Connection;

import es.udc.fbellas.j2ee.util.exceptions.InstanceNotFoundException;
import es.udc.fbellas.j2ee.util.exceptions.InternalErrorException;
import es.udc.fbellas.j2ee.util.sql.TransactionalPlainAction;
import es.udc.emarketapp.emarket.model.product.dao.SQLProductDAO;
import es.udc.emarketapp.emarket.model.product.dao.SQLProductDAOFactory;
import es.udc.emarketapp.emarket.model.product.vo.ProductVO;

public class ModifyProductAction implements TransactionalPlainAction {

    private ProductVO productVO;
    
    public ModifyProductAction(ProductVO productVO) {
        this.productVO = productVO;
    }
    
    
    public Object execute(Connection connection) 
        throws InternalErrorException, InstanceNotFoundException {        

        SQLProductDAO productDAO = SQLProductDAOFactory.getDAO();

        ProductVO product = productDAO.update(connection, productVO);
        
        return product;

    }


}

